import javax.sound.sampled.*;

public class Son {
	public static Son tir = loadSound("arme.wav");

	public static Son loadSound(String fileName) {
		Son sound = new Son();
		try {   
			AudioInputStream ais = AudioSystem.getAudioInputStream(Son.class.getResource((fileName)));

			Clip clip = AudioSystem.getClip();
			clip.open(ais);
			sound.clip = clip;
			
		} catch (Exception e) {
			System.out.println(e);
		}
		return sound;
	}

	private Clip clip;

	public void play() {
		try {
			if (clip != null) {
				new Thread() {
					public void run() {
						synchronized (clip) {
							clip.stop();
							clip.setFramePosition(0);
							clip.start();
						}
					}
				}.start();
			}
		} catch (Exception e) {
			System.out.println(e);
		}
	}
}